import { createRouter, createWebHistory } from 'vue-router'
import store from '../store'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

const routes = [
  {
    path: '/',
    name: 'Index',
    component: ()=> import('@/views/Index')
  },{
    path: '/:pathMatch(.*)*',
    name: '404',
    component: () => import ('@/views/notFound')
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

router.beforeResolve((to, from,next) => {
  NProgress.start()
  next()
})

router.beforeEach((to,form,next)=>{
  store.dispatch('removeHttpRequestList')
  next()
})

router.afterEach(() => {
  NProgress.done()
})

export default router
